babl: add a new symbol babl_format_get_encoding
authorØyvind Kolås <pippin@gimp.org>
Fri, 20 Jul 2018 14:14:18 +0000 (16:14 +0200)
committerØyvind Kolås <pippin@gimp.org>
Fri, 20 Jul 2018 14:14:18 +0000 (16:14 +0200)
This returns the string passed in to babl_format_new - without the space
suffix that babl_get_name does for non-sRGB formats.

babl/babl-format.c
babl/babl.h
export-symbols

index d2951657cf94a233bc23098a888460637fad2ed4..51e545816e2433ac175eee412a69b9ec21fbde2d 100644 (file)
@@ -710,6 +710,23 @@ const Babl * babl_format_get_space      (const Babl *format)
 
 BABL_CLASS_IMPLEMENT (format)
 
+const char *
+babl_format_get_encoding (const Babl *babl)
+{
+  static char ret[256];
+  const char *name = babl_get_name (babl);
+  strcpy (&ret[0], name);
+  if (babl_format_get_space (babl) != babl_space ("sRGB"))
+    {
+
+      if (strstr (ret, "-space"))
+        *strstr (ret, "-space") = '\0';
+
+      name = &ret[0];
+    }
+  return name;
+}
+
 const Babl *
 babl_format_with_space (const char *name, const Babl *space)
 {
index 6d58aaca624a2b26d72d94f58fe31b0e45467be0..12b09c1a4f85790303244dcdad2307584801dcd3 100644 (file)
@@ -570,6 +570,12 @@ babl_space_from_rgbxyz_matrix (const char *name,
                                const Babl *trc_green,
                                const Babl *trc_blue);
 
+/**
+ * babl_format_get_encoding:
+ *
+ * Returns the components and data type, without space suffix.
+ */
+const char * babl_format_get_encoding (const Babl *babl);
 
 #ifdef __cplusplus
 }
index d246e3d8264fc2db3ffc49055c1b37f4ea9212f2..476238e45941750bf2cb669ee1223048d882a260 100644 (file)
@@ -14,6 +14,7 @@ babl_format_get_model
 babl_format_get_n_components
 babl_format_get_space
 babl_format_get_type
+babl_format_get_encoding
 babl_format_has_alpha
 babl_format_is_format_n
 babl_format_is_palette